package com.easybuy.dao.impl;

import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.easybuy.dao.BrandDao;
import com.easybuy.entity.Brand;

@Repository("brandDao")
public class BrandDaoImpl implements BrandDao {

	@Autowired
	private SqlSessionTemplate sqlSession;

	public List<Brand> getList(String name, int first, int maxResult) {
		return sqlSession.getMapper(BrandDao.class).getList(name, first,
				maxResult);
	}

	public void add(Brand brand) {
		sqlSession.getMapper(BrandDao.class).add(brand);
	}

	public Brand getById(int id) {
		return sqlSession.getMapper(BrandDao.class).getById(id);
	}

	public void update(Brand brand) {
		sqlSession.getMapper(BrandDao.class).update(brand);
	}

	public void delete(int id) {
		sqlSession.getMapper(BrandDao.class).delete(id);
	}

	public int getCount(String name) {
		return sqlSession.getMapper(BrandDao.class).getCount(name);
	}

}
